﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a deformable surface matching result.</summary>
	// Token: 0x0200002E RID: 46
	public class HDeformableSurfaceMatchingResult : HHandle
	{
		// Token: 0x06000425 RID: 1061 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDeformableSurfaceMatchingResult() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x06000426 RID: 1062 RVA: 0x00019637 File Offset: 0x00017837
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDeformableSurfaceMatchingResult(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000427 RID: 1063 RVA: 0x00019646 File Offset: 0x00017846
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDeformableSurfaceMatchingResult(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000428 RID: 1064 RVA: 0x00019655 File Offset: 0x00017855
		private void AssertSemType()
		{
			base.AssertSemType("deformable_surface_matching_result");
		}

		// Token: 0x06000429 RID: 1065 RVA: 0x00019662 File Offset: 0x00017862
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDeformableSurfaceMatchingResult obj)
		{
			obj = new HDeformableSurfaceMatchingResult(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x0600042A RID: 1066 RVA: 0x0001967C File Offset: 0x0001787C
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDeformableSurfaceMatchingResult[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HDeformableSurfaceMatchingResult[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HDeformableSurfaceMatchingResult(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Get details of a result from deformable surface based matching.
		///   Instance represents: Handle of the deformable surface matching result.
		/// </summary>
		/// <param name="resultName">Name of the result property. Default: "sampled_scene"</param>
		/// <param name="resultIndex">Index of the result property. Default: 0</param>
		/// <returns>Value of the result property.</returns>
		// Token: 0x0600042B RID: 1067 RVA: 0x000196EC File Offset: 0x000178EC
		public HTuple GetDeformableSurfaceMatchingResult(HTuple resultName, HTuple resultIndex)
		{
			IntPtr proc = HalconAPI.PreCall(1019);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, resultName);
			HalconAPI.Store(proc, 2, resultIndex);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(resultName);
			HalconAPI.UnpinTuple(resultIndex);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get details of a result from deformable surface based matching.
		///   Instance represents: Handle of the deformable surface matching result.
		/// </summary>
		/// <param name="resultName">Name of the result property. Default: "sampled_scene"</param>
		/// <param name="resultIndex">Index of the result property. Default: 0</param>
		/// <returns>Value of the result property.</returns>
		// Token: 0x0600042C RID: 1068 RVA: 0x00019750 File Offset: 0x00017950
		public HTuple GetDeformableSurfaceMatchingResult(string resultName, int resultIndex)
		{
			IntPtr proc = HalconAPI.PreCall(1019);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, resultName);
			HalconAPI.StoreI(proc, 2, resultIndex);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>Free the memory of a deformable surface matching result.</summary>
		/// <param name="deformableSurfaceMatchingResult">Handle of the deformable surface matching result.</param>
		// Token: 0x0600042D RID: 1069 RVA: 0x000197A8 File Offset: 0x000179A8
		public static void ClearDeformableSurfaceMatchingResult(HDeformableSurfaceMatchingResult[] deformableSurfaceMatchingResult)
		{
			HTuple htuple = HHandleBase.ConcatArray(deformableSurfaceMatchingResult);
			IntPtr proc = HalconAPI.PreCall(1020);
			HalconAPI.Store(proc, 0, htuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(htuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(deformableSurfaceMatchingResult);
		}

		/// <summary>
		///   Free the memory of a deformable surface matching result.
		///   Instance represents: Handle of the deformable surface matching result.
		/// </summary>
		// Token: 0x0600042E RID: 1070 RVA: 0x000197EC File Offset: 0x000179EC
		public void ClearDeformableSurfaceMatchingResult()
		{
			IntPtr proc = HalconAPI.PreCall(1020);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>Refine the position and deformation of a deformable surface model in a 3D scene.</summary>
		/// <param name="deformableSurfaceModel">Handle of the deformable surface model.</param>
		/// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param>
		/// <param name="relSamplingDistance">Relative sampling distance of the scene. Default: 0.05</param>
		/// <param name="initialDeformationObjectModel3D">Initial deformation of the 3D object model</param>
		/// <param name="genParamName">Names of the generic parameters. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters. Default: []</param>
		/// <param name="deformableSurfaceMatchingResult">Handle of the matching result.</param>
		/// <returns>Score of the refined model.</returns>
		// Token: 0x0600042F RID: 1071 RVA: 0x00019820 File Offset: 0x00017A20
		public static HTuple RefineDeformableSurfaceModel(HDeformableSurfaceModel deformableSurfaceModel, HObjectModel3D objectModel3D, double relSamplingDistance, HObjectModel3D initialDeformationObjectModel3D, HTuple genParamName, HTuple genParamValue, out HDeformableSurfaceMatchingResult[] deformableSurfaceMatchingResult)
		{
			IntPtr proc = HalconAPI.PreCall(1026);
			HalconAPI.Store(proc, 0, deformableSurfaceModel);
			HalconAPI.Store(proc, 1, objectModel3D);
			HalconAPI.StoreD(proc, 2, relSamplingDistance);
			HalconAPI.Store(proc, 3, initialDeformationObjectModel3D);
			HalconAPI.Store(proc, 4, genParamName);
			HalconAPI.Store(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out result);
			num = HDeformableSurfaceMatchingResult.LoadNew(proc, 1, num, out deformableSurfaceMatchingResult);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(deformableSurfaceModel);
			GC.KeepAlive(objectModel3D);
			GC.KeepAlive(initialDeformationObjectModel3D);
			return result;
		}

		/// <summary>
		///   Refine the position and deformation of a deformable surface model in a 3D scene.
		///   Modified instance represents: Handle of the matching result.
		/// </summary>
		/// <param name="deformableSurfaceModel">Handle of the deformable surface model.</param>
		/// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param>
		/// <param name="relSamplingDistance">Relative sampling distance of the scene. Default: 0.05</param>
		/// <param name="initialDeformationObjectModel3D">Initial deformation of the 3D object model</param>
		/// <param name="genParamName">Names of the generic parameters. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters. Default: []</param>
		/// <returns>Score of the refined model.</returns>
		// Token: 0x06000430 RID: 1072 RVA: 0x000198C0 File Offset: 0x00017AC0
		public double RefineDeformableSurfaceModel(HDeformableSurfaceModel deformableSurfaceModel, HObjectModel3D objectModel3D, double relSamplingDistance, HObjectModel3D initialDeformationObjectModel3D, string genParamName, string genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1026);
			HalconAPI.Store(proc, 0, deformableSurfaceModel);
			HalconAPI.Store(proc, 1, objectModel3D);
			HalconAPI.StoreD(proc, 2, relSamplingDistance);
			HalconAPI.Store(proc, 3, initialDeformationObjectModel3D);
			HalconAPI.StoreS(proc, 4, genParamName);
			HalconAPI.StoreS(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 1, num);
			double result;
			num = HalconAPI.LoadD(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(deformableSurfaceModel);
			GC.KeepAlive(objectModel3D);
			GC.KeepAlive(initialDeformationObjectModel3D);
			return result;
		}

		/// <summary>Find the best match of a deformable surface model in a 3D scene.</summary>
		/// <param name="deformableSurfaceModel">Handle of the deformable surface model.</param>
		/// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param>
		/// <param name="relSamplingDistance">Scene sampling distance relative to the diameter of the surface model. Default: 0.05</param>
		/// <param name="minScore">Minimum score of the returned match. Default: 0</param>
		/// <param name="genParamName">Names of the generic parameters. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters. Default: []</param>
		/// <param name="deformableSurfaceMatchingResult">Handle of the matching result.</param>
		/// <returns>Score of the found instances of the surface model.</returns>
		// Token: 0x06000431 RID: 1073 RVA: 0x00019960 File Offset: 0x00017B60
		public static HTuple FindDeformableSurfaceModel(HDeformableSurfaceModel deformableSurfaceModel, HObjectModel3D objectModel3D, double relSamplingDistance, HTuple minScore, HTuple genParamName, HTuple genParamValue, out HDeformableSurfaceMatchingResult[] deformableSurfaceMatchingResult)
		{
			IntPtr proc = HalconAPI.PreCall(1027);
			HalconAPI.Store(proc, 0, deformableSurfaceModel);
			HalconAPI.Store(proc, 1, objectModel3D);
			HalconAPI.StoreD(proc, 2, relSamplingDistance);
			HalconAPI.Store(proc, 3, minScore);
			HalconAPI.Store(proc, 4, genParamName);
			HalconAPI.Store(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(minScore);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out result);
			num = HDeformableSurfaceMatchingResult.LoadNew(proc, 1, num, out deformableSurfaceMatchingResult);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(deformableSurfaceModel);
			GC.KeepAlive(objectModel3D);
			return result;
		}

		/// <summary>
		///   Find the best match of a deformable surface model in a 3D scene.
		///   Modified instance represents: Handle of the matching result.
		/// </summary>
		/// <param name="deformableSurfaceModel">Handle of the deformable surface model.</param>
		/// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param>
		/// <param name="relSamplingDistance">Scene sampling distance relative to the diameter of the surface model. Default: 0.05</param>
		/// <param name="minScore">Minimum score of the returned match. Default: 0</param>
		/// <param name="genParamName">Names of the generic parameters. Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters. Default: []</param>
		/// <returns>Score of the found instances of the surface model.</returns>
		// Token: 0x06000432 RID: 1074 RVA: 0x00019A00 File Offset: 0x00017C00
		public double FindDeformableSurfaceModel(HDeformableSurfaceModel deformableSurfaceModel, HObjectModel3D objectModel3D, double relSamplingDistance, double minScore, HTuple genParamName, HTuple genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1027);
			HalconAPI.Store(proc, 0, deformableSurfaceModel);
			HalconAPI.Store(proc, 1, objectModel3D);
			HalconAPI.StoreD(proc, 2, relSamplingDistance);
			HalconAPI.StoreD(proc, 3, minScore);
			HalconAPI.Store(proc, 4, genParamName);
			HalconAPI.Store(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 1, num);
			double result;
			num = HalconAPI.LoadD(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(deformableSurfaceModel);
			GC.KeepAlive(objectModel3D);
			return result;
		}
	}
}
